<%@page import="vo.boardVO"%>
<%@page import="dto.boardDTO"%>
<%@page import="java.util.ArrayList" %>
<%@page import="java.text.SimpleDateFormat"%>
<%@page import="java.util.Calendar"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<link rel="stylesheet" href="../css/board.css">
<script src = '../js/board.js'></script>
</head>
<body>
<jsp:useBean id="vo" class="vo.boardVO" scope="page"/>
<jsp:setProperty property="*" name="vo"/>

<%
	boardVO bvo = vo;

	String m_id = (String)session.getAttribute("sessionMid");
	bvo.setM_id(m_id);
	
	int category = 10;
	int form_num = 0;
	category = Integer.parseInt(request.getParameter("category"));
	form_num = Integer.parseInt(request.getParameter("form_num"));
	
// 	System.out.print(form_num);
	bvo.setB_category(category);
	
	boardDTO dto = new boardDTO(bvo);
	dto.list_size_set(5);
	dto.e_num();		// m_id를 통해서 사원의 번호를 db에서 얻어옴

	ArrayList<boardVO> al = dto.list();
	
// 	out.println("카테고리값" + vo.getB_category());
// 	out.println("아이디" + vo.getM_id());
// 	out.println("사번" + vo.getE_number());
	
%>

	<form method='post'>
		 	<input type='hidden' name="nowPage"/>
		 	<input type='hidden' name='find'/>
		 	<input type='hidden' name='b_number'/>
		 	<input type='hidden' name='b_category' value="<%=vo.getB_category()%>"/>
		 	<input type='hidden' name='m_id' value="<%=vo.getM_id()%>"/>
	 		<input type='hidden' name='e_number' value="<%=vo.getE_number() %>"/>
	</form>
	
<div id="wrap">	
	<table id="board_table">
		<tr id="board_title_items" class="board_title">
			<td id="board_title_name" class="board_title">제&nbsp;&nbsp;&nbsp;목</td>
			<td id="board_title_send_date" class="board_title">작&nbsp;성&nbsp;일</td>
		</tr>
		<%
			for(int a=0; a<al.size(); a++){
			boardVO v = al.get(a);
		%>
		 <tr id="board_list_items" class="board_list">
		 <%if(v.getB_group()==v.getB_number()){ %>
		 	<td id="board_list_name" class="board_list">
		 	&nbsp;&nbsp;
		 	<a href = '#' onclick="mini_goView('1','<%=v.getB_number()%>', <%=form_num%> )">
		 		<% 	if(v.getB_title().length()>12){
						String title = v.getB_title().substring(0, 12); %>
			    		<%=title%>...
					<%} else {%>
						<%=v.getB_title()%>
					<%}%></a>
					<% 	String date2 = (String)v.getB_date();
				 		String date3 = date2.substring(0, 10);
				   		String timeStamp = new SimpleDateFormat("yyyy-MM-dd").format(Calendar.getInstance().getTime());
					if(date3.equals(timeStamp)){%>
							<div id='board_list_b_title3'><img alt="" src="../images/icon_new.gif"> </div>
				<%}%>
		 	</td>
		 <%}else{%>
		 	<td id="board_list_name" class="board_list">
		 	&nbsp;&nbsp;
		 		<a href="#" onclick="mini_goView('1', '<%=v.getB_number() %>', <%=form_num%> )">
					<% for(int j=0; j<=(v.getB_deep()); j++){ %>
					&nbsp;
					<%} %>
					└> 
					<% if(v.getB_title().length()>12){
							String title = v.getB_title().substring(0, 12); %>
					    	<%=title%>...
						<%} else {%>
							<%=v.getB_title()%>
						<%} %>
					<% 	String date2 = (String)v.getB_date();
				 		String date3 = date2.substring(0, 10);
				   		String timeStamp = new SimpleDateFormat("yyyy-MM-dd").format(Calendar.getInstance().getTime());
					if(date3.equals(timeStamp)){%>
							<div id='board_list_b_title3'><img alt="" src="../images/icon_new.gif"> </div>
				<%}%>	
				</a>
		 	</td>
		 <%} %>
		 	<td id="board_list_send_date" class="board_list">
			 	<% 	String date = (String)v.getB_date();
					if(date.length()>10){
					String date1 = date.substring(0, 10); %>
			    	<%=date1%>
				<%} else {%>
					<%=v.getB_date()%>
				<%}%>
		 	</td>
		 </tr>
		 <%}%>	
	</table>
	
</div>
	
</body>
</html>